package com.pug.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pug.domain.Account;
import com.pug.domain.KssUser;
import com.pug.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

/**
 * @author panghu
 * @version 1.0.0
 * @createTime 2022年08月12日 23:36:00
 * @Description
 */
@Slf4j
@Service
@DubboService // 服务作为生产者暴露到zookeeper注册中心中
public class UserServiceImpl extends ServiceImpl<UserMapper, KssUser> implements UserService {

    // 引用注册中心服务
    @DubboReference(version = "1.0",check = false,loadbalance = "roundrobin")
    private PayService payService;

    /**
     * 根据用户id查询用户信息
     *
     * @param userId
     * @return
     */
    @Override
    public KssUser getUserById(Long userId) {
        // 远程和调用 - 订单服务
        Account account = payService.getAccountInfo(userId);
        KssUser user = this.getById(userId);
        user.setAccount(account);
        return user;
    }
}
